package com.neusoft.controller;

import com.fasterxml.jackson.databind.ObjectMapper;
import com.neusoft.domain.Orders;
import com.neusoft.domain.vo.OrdersVo;
import com.neusoft.service.OrdersService;
import com.neusoft.service.impl.OrdersServiceImpl;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

@RestController
@RequestMapping("/OrdersController")
public class OrdersController {

    @Autowired
    OrdersService ordersService;

    @PostMapping("/createOrders")
    public Integer createOrders(@RequestBody Orders orders) {
        return ordersService.createOrders(orders);
    }

    @GetMapping("/getOrdersById/{orderId}")
    public Orders getOrdersById(@PathVariable Integer orderId)  {
        return ordersService.getOrdersById(orderId);
    }

    @GetMapping("/listOrdersByUserId")
    public List<OrdersVo> listOrdersByUserId(String userId)  {
        return ordersService.listOrdersByUserId(userId);
    }
}
